package com.person.webdemoproject2.mapper;

import com.person.webdemoproject2.pojo.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface FindMapper {
    @Select("select id, username, create_time, update_time, picture from tb_user where id=#{userid}")
    User userinfo(Integer userid);
    @Select("select count(userrelationship.followed_person) from userrelationship where userid=#{userid}")
    Integer countf(Integer userid);
    @Select("select count(userid) from userrelationship where followed_person=#{userid}")
    Integer fans(Integer userid);

    @Select("select  username, create_time, update_time, picture from tb_user where username=#{username}")
    User byusername(String username);
    @Select("select * from userrelationship where userid=#{userid}")
    List<UserRelationship> fname(Integer userid);

    List<Post> getPostsByDate(@Param("begin") LocalDate begin,@Param("end") LocalDate end);
    @Select("select * from tb_post order by `like`desc ")
    List<Post> getPostsByLikes();

    @Select("select * from tb_post where title LIKE concat('%',#{keyword},'%')")
    List<Post> getPostsBykeyword(String keyword);
    @Select("select postid from tb_collection where userid=#{userid}")
    List<Integer> getPostid(Integer userid);
    @Select("select * from tb_post where id=#{postid}")
    Post Conllections(Integer postid);
    @Select("select * from tb_comment where postid=#{postId}")
    List<Comment> comments(Integer postId);
    @Select("select * from tb_recomment where comment_id=#{commentId}")
    List<reComment> recomments(Integer commentId);
    @Select("select followed_person from userrelationship where userid=#{userid}")
    List<Integer> byuserid(Integer userid);
    @Select("select * from tb_post where userid=#{userid}")
    List<Post> GetPostByuserid(Integer userid);
    @Select("select * from tb_comment where userid=#{userId}")
    List<Comment> GetCommentByuserid(Integer userId);
    @Select("select * from tb_post where id=#{postId}")
    Post getPostById(Integer postId);
}
